<template>
  <div class="langSelect">
    <el-dropdown id="langselect" trigger="click" @command='handleLanguage'>
      <span class="el-dropdown-link">
        <el-tooltip content="国际化">
          <i class="iconfont icon-cvs-fanyi"></i>
        </el-tooltip>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item :disabled="language == 'zh'" command="zh">中文</el-dropdown-item>
        <el-dropdown-item :disabled="language == 'en'" command="en">English</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
import i18n from "../../i18n/index"
export default {
  data() {
    return {};
  },
  mounted() {},
  computed: {
      language(){
        return this.$store.getters.language
     }
  },
  methods: {
      handleLanguage(val){
       this.$store.commit("app/setLanguage",val)
       
       i18n.locale = this.language
    
       this.$message.success(i18n.t('msg.toast.switchLangSuccess'))
   }
  },
};
</script>

<style scoped lang='scss'>
.icon-cvs-fanyi{
    font-size: 23px;
}
</style>
